<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<script type="text/javascript" src="<c:url value="/resources/qrcode/qrcode.min.js"/>"></script>
<style>
    #qrcodeDiv {
        width:100px;
        height:100px;
        margin-top:15px;
    }
    .deleteImg{
        width: 20px;
        position: relative;
        top: -100px;
        left: 100px;
        cursor: pointer;
        display: none;
    }
    .startImg{
        width: 100px;
        height: 100px;
        /*margin-left: 30px;*/
    }
    .panel-success > .panel-heading {
        background-color: #1c84c6;
        border-color: #1c84c6;
        color: #ffffff;
    }
</style>
<script type="text/javascript">
    var qrcode = new QRCode(document.getElementById("qrcodeDiv"), {
        width : 100,
        height : 100
    });

    function makeCode () {
        qrcode.makeCode('${qrCodeString}');
    }

    makeCode();

    // $("#text").
    // on("blur", function () {
    //     makeCode();
    // }).
    // on("keydown", function (e) {
    //     if (e.keyCode == 13) {
    //         makeCode();
    //     }
    // });
</script>

<div class="main-content">
    <div class="box box-main">
        <form id="facilityForm" model="post" action="<c:url value="/web/admin/facility/executeFacilityEdit.action"/>" method="post" class="form-horizontal" enctype="multipart/form-data">
            <div class="box-body">
                <div class="accordion-group">
                    <div class="accordion-heading" style="margin-bottom: 5px">
                        <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseOne">
                            <div class="panel panel-success">
                                <div class="panel-heading">
                                    基础信息
                                </div>
                            </div>
                        </a>
                    </div>
                    <div id="collapseOne" class="accordion-body collapse in">
                        <div class="accordion-inner">
                            <div class="row">
                                <div class="col-xs-6">
                                    <div class="form-group">
                                        <label class="control-label col-sm-4" title="">
                                            <span class="required ">*</span> 设备名称：<i class="fa icon-question hide"></i></label>
                                        <div class="col-sm-8">
                                            <input path="name" name="name" value="${facility.name}" maxlength="100" class="form-control required">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-xs-6">
                                    <div class="form-group">
                                        <label class="control-label col-sm-4" title="">
                                            <span class="required ">*</span> 设备编号：<i class="fa icon-question hide"></i></label>
                                        <div class="col-sm-8">
                                            <input path="code" name="code" value="${facility.code}" maxlength="100" class="form-control required">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-xs-6">
                                    <div class="form-group">
                                        <label class="control-label col-sm-4" title="">
                                            生产厂家：<i class="fa icon-question hide"></i></label>
                                        <div class="col-sm-8">
                                            <input path="factory" name="factory" value="${facility.factory}" maxlength="100" class="form-control ">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-xs-6">
                                    <div class="form-group">
                                        <label class="control-label col-sm-4" title="">
                                            规格型号：<i class="fa icon-question hide"></i></label>
                                        <div class="col-sm-8">
                                            <input path="type" name="type" value="${facility.type}" maxlength="100" class="form-control ">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-xs-6">
                                    <div class="form-group">
                                        <label class="control-label col-sm-4" title="">
                                            所属专业：<i class="fa icon-question hide"></i></label>
                                        <div class="col-sm-8">
                                            <input path="selectRootCatId" id="selectRootCatId" name="selectRootCatId" class="form-control">
                                            <input type="hidden" id="rootCatId" value="-1">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-xs-6">
                                    <div class="form-group">
                                        <label class="control-label col-sm-4" title="">
                                            所属类型：<i class="fa icon-question hide"></i></label>
                                        <div class="col-sm-8">
                                            <input path="selectCatId" id="selectCatId" name="selectCatId" class="form-control">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-xs-6">
                                    <div class="form-group">
                                        <label class="control-label col-sm-4" title="">
                                            所属分组：<i class="fa icon-question hide"></i></label>
                                        <div class="col-sm-8">
                                            <input path="selectGroupId" id="selectGroupId" name="selectGroupId" class="form-control">
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="accordion-group">
                    <div class="accordion-heading" style="margin-bottom: 5px">
                        <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseTwo">
                            <div class="panel panel-success">
                                <div class="panel-heading">
                                    位置信息
                                </div>
                            </div>
                        </a>
                    </div>
                    <div id="collapseTwo" class="accordion-body collapse in">
                        <div class="accordion-inner">
                            <div class="row">
                                <div class="col-xs-6">
                                    <div class="form-group">
                                        <label class="control-label col-sm-4" title="">
                                            所属区域：<i class="fa icon-question hide"></i></label>
                                        <div class="col-sm-8">
                                            <input path="selectAreaId" id="selectAreaId" name="selectAreaId" class="form-control">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-xs-6">
                                    <div class="form-group">
                                        <label class="control-label col-sm-4" title="">
                                            位置：<i class="fa icon-question hide"></i></label>
                                        <div class="col-sm-8">
                                            <input path="position" name="position" value="${facility.position}" maxlength="100" class="form-control ">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-xs-6">
                                    <div class="form-group">
                                        <label class="control-label col-sm-4" title="">
                                            具体位置：<i class="fa icon-question hide"></i></label>
                                        <div class="col-sm-8">
                                            <input path="precisePosition" name="precisePosition" value="${facility.precisePosition}" maxlength="100" class="form-control ">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-xs-6">
                                    <div class="form-group">
                                        <label class="control-label col-sm-4" title="">
                                            详细位置：<i class="fa icon-question hide"></i></label>
                                        <div class="col-sm-8">
                                            <input path="detailPosition" name="detailPosition" value="${facility.detailPosition}" maxlength="100" class="form-control ">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-xs-6">
                                    <div class="form-group">
                                        <label class="control-label col-sm-4" title="">
                                            经度：<i class="fa icon-question hide"></i></label>
                                        <div class="col-sm-8">
                                            <input path="longitude" name="longitude1" value="${facility.longitude}" maxlength="100" class="form-control ">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-xs-6">
                                    <div class="form-group">
                                        <label class="control-label col-sm-4" title="">
                                            纬度：<i class="fa icon-question hide"></i></label>
                                        <div class="col-sm-8">
                                            <input path="latitude" name="latitude1" value="${facility.latitude}" maxlength="100" class="form-control ">
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="accordion-group">
                    <div class="accordion-heading" style="margin-bottom: 5px">
                        <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseThree">
                            <div class="panel panel-success">
                                <div class="panel-heading">
                                    详细信息
                                </div>
                            </div>
                        </a>
                    </div>
                    <div id="collapseThree" class="accordion-body collapse in">
                        <div class="accordion-inner">
                            <div class="row">
                                <div class="col-xs-6">
                                    <div class="form-group">
                                        <label class="control-label col-sm-4" title="">
                                            序列号：<i class="fa icon-question hide"></i></label>
                                        <div class="col-sm-8">
                                            <input path="serialNum" name="serialNum" value="${facility.serialNum}" maxlength="100" class="form-control">
                                        </div>
                                    </div>
                                </div>
                                <%--<div class="col-xs-6">--%>
                                    <%--<div class="form-group">--%>
                                        <%--<label class="control-label col-sm-4" title="">--%>
                                            <%--TPM指导书：<i class="fa icon-question hide"></i></label>--%>
                                        <%--<div class="col-sm-8">--%>
                                            <%--<input path="tpmBook" name="tpmBook" value="${facility.tpmBook}" maxlength="100" class="form-control ">--%>
                                        <%--</div>--%>
                                    <%--</div>--%>
                                <%--</div>--%>
                                <div class="col-xs-6">
                                    <div class="form-group">
                                        <label class="control-label col-sm-4" title="">
                                            保用期：<i class="fa icon-question hide"></i></label>
                                        <div class="col-sm-8">
                                            <input path="guarantee" name="guarantee" value="${facility.guarantee}" maxlength="100" class="form-control ">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-xs-6">
                                    <div class="form-group">
                                        <label class="control-label col-sm-4" title="">
                                            出厂日期：<i class="fa icon-question hide"></i></label>
                                        <div class="col-sm-8">
                                            <input type="text" class="form-control" id="releaseDate" name="releaseDate" value="${facility.releaseDate}" autoComplete="off"/>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-xs-6">
                                    <div class="form-group">
                                        <label class="control-label col-sm-4" title="">
                                            启用日期：<i class="fa icon-question hide"></i></label>
                                        <div class="col-sm-8">
                                            <input type="text" class="form-control" id="enableDate" name="enableDate" value="${facility.enableDate}" autoComplete="off"/>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-xs-6">
                                    <div class="form-group">
                                        <label class="control-label col-sm-4" title="">
                                            上级电源：<i class="fa icon-question hide"></i></label>
                                        <div class="col-sm-8">
                                            <input path="upPower" name="upPower" value="${facility.upPower}" maxlength="100" class="form-control ">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-xs-6">
                                    <div class="form-group">
                                        <label class="control-label col-sm-4" title="">
                                            备用电源：<i class="fa icon-question hide"></i></label>
                                        <div class="col-sm-8">
                                            <input path="sparePower" name="sparePower" value="${facility.sparePower}" maxlength="100" class="form-control ">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-xs-6">
                                    <div class="form-group">
                                        <label class="control-label col-sm-4" title="">
                                            所属系统：<i class="fa icon-question hide"></i></label>
                                        <div class="col-sm-8">
                                            <input path="belongSystem" name="belongSystem" value="${facility.belongSystem}" maxlength="100" class="form-control ">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-xs-6">
                                    <div class="form-group">
                                        <label class="control-label col-sm-4" title="">
                                            所属子系统：<i class="fa icon-question hide"></i></label>
                                        <div class="col-sm-8">
                                            <input path="subSystem" name="subSystem" value="${facility.subSystem}" maxlength="100" class="form-control ">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-xs-6">
                                    <div class="form-group">
                                        <label class="control-label col-sm-4" title="">
                                            重要程度：<i class="fa icon-question hide"></i></label>
                                        <div class="col-sm-8">
                                            <select class="form-control" name="importantDegree">
                                                <option <c:if test="${facility.importantDegree=='A'}">selected</c:if>>A</option>
                                                <option <c:if test="${facility.importantDegree=='B'}">selected</c:if>>B</option>
                                                <option <c:if test="${facility.importantDegree=='C'}">selected</c:if>>C</option>
                                            </select>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-xs-6">
                                    <div class="form-group">
                                        <label class="control-label col-sm-4" title="">
                                            功率：<i class="fa icon-question hide"></i></label>
                                        <div class="col-sm-8">
                                            <input path="power" name="power" value="${facility.power}" maxlength="100" class="form-control ">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-xs-6">
                                    <div class="form-group">
                                        <label class="control-label col-sm-4" title="">
                                            网格化责任人：<i class="fa icon-question hide"></i></label>
                                        <div class="col-sm-8">
                                            <input path="gridPerson" name="gridPerson" value="${facility.gridPerson}" maxlength="100" class="form-control ">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-xs-6">
                                    <div class="form-group">
                                        <label class="control-label col-sm-4" title="">
                                            所属主设备：<i class="fa icon-question hide"></i></label>
                                        <div class="col-sm-8">
                                            <input path="selectParentId" id="selectParentId" name="selectParentId" class="form-control">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-xs-6">
                                    <div class="form-group">
                                        <label class="control-label col-sm-4" title="">
                                            所属部门：<i class="fa icon-question hide"></i></label>
                                        <div class="col-sm-8">
                                            <input path="selectOrganizationId" id="selectOrganizationId" name="selectOrganizationId" class="form-control">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-xs-12">
                                    <div class="form-group">
                                        <label class="control-label col-sm-2" title="">
                                            功能/用途：<i class="fa icon-question hide"></i></label>
                                        <div class="col-sm-8">
                                            <textarea id="purpose" name="purpose" rows="4" maxlength="500" class="form-control ">${facility.purpose}</textarea>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-xs-12">
                                    <div class="form-group">
                                        <label class="control-label col-sm-2" title="">
                                            主要技术参数：<i class="fa icon-question hide"></i></label>
                                        <div class="col-sm-8">
                                            <textarea id="mainParm" name="mainParm" rows="4" maxlength="500" class="form-control ">${facility.mainParm}</textarea>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="accordion-group">
                    <div class="accordion-heading" style="margin-bottom: 5px">
                        <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseFour">
                            <div class="panel panel-success">
                                <div class="panel-heading">
                                    补充信息
                                </div>
                            </div>
                        </a>
                    </div>
                    <div id="collapseFour" class="accordion-body collapse in">
                        <div class="accordion-inner">
                            <div class="row">
                                <div class="col-xs-6">
                                    <div class="form-group">
                                        <label class="control-label col-sm-4" title="">
                                            成本中心：<i class="fa icon-question hide"></i></label>
                                        <div class="col-sm-8">
                                            <input path="costCenter" name="costCenter" value="${facility.costCenter}" maxlength="100" class="form-control ">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-xs-6">
                                    <div class="form-group">
                                        <label class="control-label col-sm-4" title="">
                                            固定资产编号：<i class="fa icon-question hide"></i></label>
                                        <div class="col-sm-8">
                                            <input path="faCode" name="faCode" value="${facility.faCode}" maxlength="100" class="form-control ">
                                        </div>
                                    </div>
                                </div>

                                <div class="col-xs-6">
                                    <div class="form-group">
                                        <label class="control-label col-sm-4" title="">
                                            二维码值：<i class="fa icon-question hide"></i></label>
                                        <div class="col-sm-8">
                                            <input path="qrCode" name="qrCode" value="${facility.qrCode}" maxlength="200" class="form-control ">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-xs-6">
                                    <div class="form-group">
                                        <label class="control-label col-sm-4" title="">
                                            二维码：<i class="fa icon-question hide"></i></label>
                                        <div class="col-sm-8">
                                            <div id="qrcodeDiv"></div>
                                        </div>
                                    </div>
                                </div>
                                <%--<div class="col-xs-6">--%>
                                    <%--<div class="form-group">--%>
                                        <%--<label class="control-label col-sm-4" title="">--%>
                                            <%--是否高能：<i class="fa icon-question hide "></i></label>--%>
                                        <%--<div class="col-sm-8">--%>
                                            <%--<input type="checkbox" class="form-control" id="highEnergy" name="highEnergy"--%>
                                                   <%--<c:if test="${facility.highEnergy==true}">checked</c:if>--%>
                                                   <%--style="margin-top: auto;margin-bottom: auto"/>--%>
                                        <%--</div>--%>
                                    <%--</div>--%>
                                <%--</div>--%>

                                <div class="col-xs-6">
                                    <div class="form-group">
                                        <label class="control-label col-sm-4" title="">
                                            现场照片：<i class="fa icon-question hide"></i></label>
                                        <div class="col-sm-8">
                                            <div style="width: 100px;">
                                                <img class="startImg" id="img1"  src="<c:url value="/resources/images/2.png" />" onclick="$('#pic1').click();"/>
                                                <img class="deleteImg" id="delete1" src="<c:url value="/resources/images/delete.png"/>" onclick="delectImg(1)"/>
                                                <input type="file" style="display: none;" name="pic1" id="pic1" onchange="getimgload(1)"/>
                                                <input type="hidden" id="sImg1" name="sImg1" value="0"><%--判断有没有变更图片用的 变了就为1 不变就为0--%>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-xs-6">
                                    <div class="form-group">
                                        <label class="control-label col-sm-4" title="">
                                            铭牌照片：<i class="fa icon-question hide"></i></label>
                                        <div class="col-sm-8">
                                            <div style="width: 100px;">
                                                <img class="startImg" id="img2"  src="<c:url value="/resources/images/2.png" />" onclick="$('#pic2').click();"/>
                                                <img class="deleteImg" id="delete2" src="<c:url value="/resources/images/delete.png"/>" onclick="delectImg(2)"/>
                                                <input type="file" style="display: none;" name="pic2" id="pic2" onchange="getimgload(2)"/>
                                                <input type="hidden" id="sImg2" name="sImg2" value="0"><%--判断有没有变更图片用的 变了就为1 不变就为0--%>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-xs-6">
                                    <div class="form-group">
                                        <label class="control-label col-sm-4" title="">
                                            是否室内：<i class="fa icon-question hide "></i></label>
                                        <div class="col-sm-8">
                                            <input type="checkbox" class="form-control" id="indoor" name="indoor"
                                                   <c:if test="${facility.indoor==true}">checked</c:if>
                                                   style="margin-top: auto;margin-bottom: auto"/>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-xs-6">
                                    <div class="form-group">
                                        <label class="control-label col-sm-4" title="">
                                            是否有效：<i class="fa icon-question hide "></i></label>
                                        <div class="col-sm-8">
                                            <input type="checkbox" class="form-control" id="effective" name="effective"
                                                   <c:if test="${facility.effective==true}">checked</c:if>
                                                   style="margin-top: auto;margin-bottom: auto"/>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <input type="hidden" name="id" value="${facility.id}"/>
                <input type="hidden" name="serialCode" value="${facility.serialCode}"/>
                <input type="hidden" name="createDate" value="<fmt:formatDate value="${facility.createDate}" pattern="yyyy-MM-dd HH:mm:ss"/>"/>
            </div>
            <div class="box-footer">
                <div class="row">
                    <div class="col-sm-offset-2 col-sm-12">
                        <button type="submit" class="btn btn-sm btn-primary" id="btnSubmitNotClose" onclick="noClose()"><i class="fa fa-check-square-o"></i> 保存并继续</button>&nbsp;
                        <button type="submit" class="btn btn-sm btn-primary" id="btnSubmit"><i class="fa fa-check"></i> 保 存</button>&nbsp;
                        <c:if test="${facility.id==null}">
                            <button type="button" class="btn btn-sm btn-primary" id="btnReset" onclick="goClear()"><i class="fa fa-reply-all"></i> 重 置</button>&nbsp;
                        </c:if>
                        <button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="closeView()"><i class="fa fa-times"></i> 关 闭</button>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>
<script>
    $('#highEnergy').bootstrapSwitch({
        onText: "是",
        offText: "否",
        onColor: "success",
        offColor: "info"
    });
    $('#indoor').bootstrapSwitch({
        onText: "是",
        offText: "否",
        onColor: "success",
        offColor: "info"
    });
    $('#effective').bootstrapSwitch({
        onText: "是",
        offText: "否",
        onColor: "success",
        offColor: "info"
    });

    $("#releaseDate").datetimepicker({format: 'yyyy-mm-dd', minView: "month",autoclose: true});
    $("#enableDate").datetimepicker({format: 'yyyy-mm-dd', minView: "month",autoclose: true});

    var flag = false;
    function noClose() {
        // 保留并继续，页面不关闭
        flag = true;
    }

    $("#facilityForm").validate({
        submitHandler: function(form){
            js.ajaxSubmitForm($(form), function(data){
                js.showMessage(data.msg);
                if(data.status == Global.NO){
                    if(!flag){
                         closeView();
                    }
                    $('#dataGrid').dataGrid("refresh");
                }
            }, "json");
        }
    });

    var selectRootCatId = $('#selectRootCatId').magicSuggest({
        allowFreeEntries: false,
        data: '<c:url value="/web/admin/facilityCat/getFacilityCatSelect.action?parentCatId=0&id=${rootCatId}" />',
        queryParam: 'q',
        valueField: "value",
        displayField: "text",
        maxSelection: 1,
        noSuggestionText: '',
        placeholder: '请选择',
        autoSelect: true,
        selectFirst: true,
        value: magicSuggestValue('${rootCatId}')
    });
    $(selectRootCatId).on('selectionchange', function (e, m) {
        $('#rootCatId').val(selectRootCatId.getValue()[0]);//更新最新的专业（既最上级类型ID）
        selectCatId.clear(true);
    });

    var selectCatId = $('#selectCatId').magicSuggest({
        allowFreeEntries: false,
        data: '<c:url value="/web/admin/facilityCat/getFacilityCatSelect.action?id=${facility.facilityCat.id}" />',
        queryParam: 'q',
        valueField: "value",
        displayField: "text",
        maxSelection: 1,
        noSuggestionText: '',
        placeholder: '请选择',
        autoSelect: true,
        selectFirst: true,
        value: magicSuggestValue('${facility.facilityCat.id}')
    });
    $(selectCatId).on('beforeload', function (e, m) {
        selectCatId.setDataUrlParams({"parentCatId":$('#rootCatId').val()});
    });

    var selectGroupId = $('#selectGroupId').magicSuggest({
        allowFreeEntries: false,
        data: '<c:url value="/web/admin/facilityGroup/getFacilityGroupSelect.action?id=${facility.facilityGroup.id}" />',
        queryParam: 'q',
        valueField: "value",
        displayField: "text",
        maxSelection: 1,
        noSuggestionText: '',
        placeholder: '请选择',
        autoSelect: true,
        selectFirst: true,
        value: magicSuggestValue('${facility.facilityGroup.id}')
    });

    var selectParentId = $('#selectParentId').magicSuggest({
        allowFreeEntries: false,
        data: '<c:url value="/web/admin/facility/getFacilitySelect.action?id=${facility.parentId}" />',
        queryParam: 'q',
        valueField: "value",
        displayField: "text",
        maxSelection: 1,
        noSuggestionText: '',
        placeholder: '请选择',
        autoSelect: true,
        selectFirst: true,
        value: magicSuggestValue('${facility.parentId}')
    });

    var selectAreaId = $('#selectAreaId').magicSuggest({
        allowFreeEntries: false,
        data: '<c:url value="/web/admin/area/getAreaSelect.action?id=${facility.area.id}" />',
        queryParam: 'q',
        valueField: "value",
        displayField: "text",
        maxSelection: 1,
        noSuggestionText: '',
        placeholder: '请选择',
        autoSelect: true,
        selectFirst: true,
        value: magicSuggestValue('${facility.area.id}')
    });

    var selectOrganizationId = $('#selectOrganizationId').magicSuggest({
        allowFreeEntries: false,
        data: '<c:url value="/web/admin/organization/getOrganizationListMagic.action?id=${facility.organization.id}" />',
        queryParam: 'q',
        valueField: "value",
        displayField: "text",
        maxSelection: 1,
        noSuggestionText: '',
        placeholder: '请选择',
        autoSelect: true,
        selectFirst: true,
        value: magicSuggestValue('${facility.organization.id}')
    });

    function closeView() {
        layer.close(LayWin['wFacility']);
    }

    function goClear() {
        $(':input','#facilityForm')
            .not(':button,:submit,:reset')   //将facilityForm表单中input元素type为button、submit、reset排除
            .val('');  //将input元素的value设为空值

        // 清除下拉框选项
        selectRootCatId.clear();
        selectCatId.clear();
        selectGroupId.clear();
        selectParentId.clear();
        selectAreaId.clear();
        selectOrganizationId.clear();
        // 恢复开关选项默认值
        $('#highEnergy').bootstrapSwitch('state',false);
        $('#indoor').bootstrapSwitch('state',false);
        $('#effective').bootstrapSwitch('state',false);
        delectImg(1);
        delectImg(2);
    }
</script>
<script>
    function delectImg(id) {
        $("#sImg"+id).val('1');//表示图片变更了（或者删掉了 总之不是原来的图片了）
        $("#pic"+id).val('');
        $("#img"+id).attr("src","<c:url value="/resources/images/2.png" />");
        $("#delete"+id).hide();
    }

    function getimgload(id){
        var obj=document.getElementById("pic"+id);
        var stuff=obj.value.match(/^(.*)(\.)(.{1,8})$/)[3];
        console.log(stuff);
        if (stuff != 'jpg' && stuff != 'png' && stuff != 'jpeg') {
            alert('图片类型不正确');
            return false;
        }
        //判断图片
        if (stuff == 'jpg' || stuff == 'png' || stuff == 'jpeg') {
            var file=document.getElementById("pic"+id).files[0];
            var reader=new FileReader();
            reader.onload = function ( event ) {
                if(!/image\/\w+/.test(file.type)){
                    alert("文件必须为图片！");
                    return false;
                }
                src = event.target.result;
                $("#img"+id).attr("src",src);
            };
            reader.readAsDataURL(file);
        }
        $("#sImg"+id).val('1');//表示图片变更了（总之不是原来的图片了）
        $("#delete"+id).show();
    }
</script>
<script>
    $(document).ready(function () {
        if(${fieldPhoto!=null&&fieldPhoto!=''}){
            $("#img1").attr("src","${fieldPhoto}");
            $("#delete1").show();
        }
        if(${platePhoto!=null&&platePhoto!=''}){
            $("#img2").attr("src","${platePhoto}");
            $("#delete2").show();
        }
    });
</script>


